// xpress-validator 结果统一处理
const { validationResult } = require("express-validator");

function validate(req, res, next) {
    const errors = validationResult(req);
    if (errors.isEmpty()) return next();
    return res.status(400).json({
        message: "参数校验失败",
        errors: errors.array(),
    });
}

module.exports = validate;
